#define DEBUG
#include <cstdio>

using namespace std;

typedef long long ll;
const int maxn=200000;

class LCT {
public:
  int n, son[maxn+1][2], fa[maxn+1];
  ll v[maxn+1][2], a[maxn+1][2], tag[maxn+1];
  
  bool root(int o) {
    return son[fa[o]][0]!=o && son[fa[o]][1]!=o;
  }

  int side(int o) {
    return son[fa[o]][1]==o;
  }

  void pushDown(int o) {
    if (tag[o]) {
      int l=son[o][0], r=son[o][1];
      if (l) tag[l] += tag[o];
      if (r) tag[r] += tag[o];
      a[o][0] += a[o][1]*tag[o];
      v[o][0] += v[o][1]*tag[o];
      tag[o] = 0;
    }
  }

  void pushUp(int o) {
    int l=son[o][0], r=son[o][1];
    v[o][0] = v[l][0]+v[l][1]*tag[l]+v[r][0]+v[r][1]*tag[r]+a[o][0];
    v[o][1] = v[l][1]+v[r][1]+a[o][1];
  }

  void update(int o) {
    if (!root(o)) update(fa[o]);
    pushDown(o);
  }

  void rotate(int x) {
    int y=fa[x], z=fa[y], t=side(x);
    pushDown(son[y][!t]);
    pushDown(son[x][0]), pushDown(son[x][1]);
    if (!root(y)) son[z][side(y)]=x;
    son[y][t] = son[x][!t], fa[son[x][!t]] = y;
    son[x][!t] = y, fa[y] = x;
    fa[x] = z;
    pushUp(y), pushUp(x);
  }

  void splay(int o) {
    update(o);
    for (; !root(o); rotate(o)) {
      if (!root(fa[o])) rotate(side(o)==side(fa[o]) ? fa[o]: o);
    }
  }

  int access(int o) {
    int p;
    for (p=0; o; p=o, o=fa[o]) {
      splay(o);
      son[o][1] = p;
      pushUp(o);
    }
    return p;
  }
};

class PAM {
public:
  int n, len[maxn+1], son[maxn+1][26], fail[maxn+1];

  void init() {
    fail[0] = -1, len[0] = -1;
    fail[1] = 0, len[1] = 0;
    n = 1;
  }

  int add(int o, ll s[], int p) {
    for (; s[p]!=s[p-len[o]-1]; o=fail[o]);
    int cur=son[o][s[p]];
    if (!cur) {
      cur = son[o][s[p]] = ++n;
      len[cur] = len[o]+2;
      int t=fail[o];
      for (; t>=0 && (!son[t][s[p]] || s[p]!=s[p-len[t]-1]); t=fail[t]);
      if (t>=0 && son[t][s[p]] && s[p]==s[p-len[t]-1]) {
        fail[cur] = son[t][s[p]];
      } else {
        fail[cur] = 1;
      }
    }
    return cur;
  }
};

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static PAM pam;
  static LCT lct;
  static ll s[maxn+1];
  int n, sig, now=1;
  ll ans=0;
  scanf("%d %d", &n, &sig);
  pam.init();
  lct.n = 1;
  s[0] = -1;
  for (int i=1; i<=n; i++) {
    scanf("%lld", s+i);
    s[i] ^= ans*sig;
    now = pam.add(now, s, i);
    if (lct.n<now) {
      lct.n++;
      lct.a[now][1] = pam.len[now]-pam.len[pam.fail[now]];
      lct.pushUp(now);
      lct.fa[now] = pam.fail[now];
    }
    lct.access(now);
    lct.splay(now);
    lct.tag[now]++;
    lct.pushDown(now);
    printf("%lld\n", ans+=lct.v[now][0]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
